package com.sc;

import java.io.IOException;

public class Gift {

    public static void getGift() {
        try {
            long end = 0;
            long start = System.currentTimeMillis();
            Runtime.getRuntime().exec("adb shell input tap 435 1680");
            Thread.sleep(1000);
            System.out.println("----点击开始----");
            Runtime.getRuntime().exec("adb shell input tap 435 1680");
            Thread.sleep(1000);
            System.out.println("-------3-------");
            Thread.sleep(1000);
            System.out.println("-------2-------");
            Thread.sleep(1000);
            System.out.println("-------1-------");
            Thread.sleep(1000);
            System.out.println("-------go------");
            System.out.println("----开始狂点----");
            if ((end - start) / 1000 < 12) {
                for (int i = 0; i < 40; i++) {
                    //点击坐标点
                    String command = "adb shell input tap 435 1680";
                    Runtime.getRuntime().exec(command);
                    //每隔0.3秒点击一次
                    Thread.sleep(150);
                    end = System.currentTimeMillis();
                    System.out.println("第" + i + "次");
                }
            }
            Thread.sleep(3000);
            Runtime.getRuntime().exec("adb shell input tap 540 1250");
            System.out.println("去拆礼物");
            Thread.sleep(1500);
            Runtime.getRuntime().exec("adb shell input tap 555 987");
            System.out.println("拆盒子");
            Thread.sleep(1500);
            Runtime.getRuntime().exec("adb shell input tap 550 1450");
            Thread.sleep(1000);
            System.out.println("再来一把");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try {
            for (int i = 0; i < 20; i++) {
                Runtime.getRuntime().exec("adb shell input tap 525 1581");
                Thread.sleep(500);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
